<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once(dirname(__FILE__) . "/../common/EasyMysql.php");
require_once(dirname(__FILE__) . "/../config/ConfigDB.php");
/**
 * Description of PayOrderCom
 *
 * @author Administrator
 */
class PayOrderCom {
    //put your code here
    function __construct() {
        $dbconfig = $GLOBALS["config"] ['database'];
        $mysql = new EasyMysql($dbconfig['hostname'], $dbconfig ['port'], $dbconfig ['username'], $dbconfig ['password'], $dbconfig ['db'], $dbconfig ['charset']);
        $this->mysql = $mysql;
    }
    function getAllOrder($minlimit,$count){
        try{
            $sql = "select * from pay_order order by id desc limit {$minlimit},{$count}";
            $ret = $this->mysql->query($sql);
            if (!empty($ret) && !empty($ret [0]) && !empty($ret [0][0])) {
                return $ret [0];
            }
        } catch (Exception $ex) {
            return false;
        }
        return null;
    }
    function getNumber() {
        try {
            $sql = "select count(1) from pay_order";
            $ret = $this->mysql->query($sql);
            if (!empty($ret) && !empty($ret [0]) && !empty($ret [0][0])) {
                return $ret[0][0]['count(1)'];
            }
        } catch (Exception $ex) {
            return false;
        }
        return 0;
    }
    function getAllCou($minlimit,$count){
        try{
            $sql = "select * from my_use_coupon order by id desc limit {$minlimit},{$count}";
            $ret = $this->mysql->query($sql);
            if (!empty($ret) && !empty($ret [0]) && !empty($ret [0][0])) {
                return $ret [0];
            }
        } catch (Exception $ex) {
            return false;
        }
        return null;
    }
    function getCouNumber(){
        try {
            $sql = "select count(1) from my_use_coupon";
            $ret = $this->mysql->query($sql);
            if (!empty($ret) && !empty($ret [0]) && !empty($ret [0][0])) {
                return $ret[0][0]['count(1)'];
            }
        } catch (Exception $ex) {
            return false;
        }
        return 0;
    }
    
    function getOrderdata($mintime,$maxtime){
        try{
            $sql = "select * from pay_order where create_time>{$mintime} and create_time<{$maxtime}";
            $ret = $this->mysql->query($sql);
            if (!empty($ret) && !empty($ret [0]) && !empty($ret [0][0])) {
                return $ret[0];
            }
        } catch (Exception $ex) {
            return false;
        }
        return null;
    }
    
    function getCoupondata($mintime,$maxtime){
        try{
            $sql = "select * from my_use_coupon where time>{$mintime} and time<{$maxtime}";
            $ret = $this->mysql->query($sql);
            if (!empty($ret) && !empty($ret [0]) && !empty($ret [0][0])) {
                return $ret[0];
            }
        } catch (Exception $ex) {
            return false;
        }
        return null;
    }
    
}
